layui.use(top.layuiuse,
    function () {
        let form = layui.form;
        let $ = layui.jquery;
        let layer = layui.layer;
        let kaBgUrl = layui.kaBgUrl;
        let kaAjax = layui.kaAjax;
        let cardTable = layui.cardTable;
        var kaAjaxFormData = {};
        kaAjax.ajax(kaBgUrl.url("getTheApp"), function (rs) {
            if (rs.code == 200) {
                var data = rs.data;
                var timeApp = data.timeApp;
                var contentApp = data.contentApp;
                var currentTable = cardTable.render({
                    elem: '#currentTableId',
                    headers: { token: 'sasasas' },
                    page: false,
                    data: contentApp,
                    linenum: 6
                })
                var currentUser = layui.kaCurrentUser.get().data;
                var mainSysApp = currentUser.mainSysApp;
                if (mainSysApp != undefined && mainSysApp != null && mainSysApp != "") {
                    loadLocationHref(mainSysApp, 2, true);
                }
            }
        }, kaAjaxFormData);
    }
)

function loadLocationHref(id, type, startBoolean) {
    var currentUser = layui.kaCurrentUser.get().data;
    var mainSysApp = currentUser.mainSysApp;
    if (mainSysApp == undefined || mainSysApp == null || mainSysApp == "") {
        var kaAjaxFormData = {"id": id};
        layui.kaAjax.ajax(layui.kaBgUrl.url("setUserMainSysApp"), function (rs) {
            if (rs.code == 200) {
                top.currentUser = layui.kaCurrentUser.get().data;
                if(type == 2){
                    top.location.href = "home.html";
                }
            }
        }, kaAjaxFormData);
    } else {
       if (startBoolean) {
            if (type == 2) {
                top.location.href = "home.html";
            }
        } else {
            var kaAjaxFormData = { "id": id };
            layui.kaAjax.ajax(layui.kaBgUrl.url("setUserMainSysApp"), function (rs) {
                if (rs.code == 200) {
                    top.currentUser = layui.kaCurrentUser.get().data;
                    if (type == 2) {
                        top.location.href = "home.html";
                    }
                }
            }, kaAjaxFormData);
        }
    }
}